﻿using System.Linq;

namespace IntellectShop.Common
{
	public partial class ScheduleItem
	{
		public static ScheduleItem RetrieveByScheduleItemID(int scheduleItemID)
		{
			using (DB.IntellectShopDataContext dataContext = new DB.IntellectShopDataContext(Common.Globals.ConnectionString))
			{
				var query = (
							from scheduleItems in dataContext.ScheduleItems
							where scheduleItems.ScheduleItemID == scheduleItemID
							select scheduleItems).SingleOrDefault();

				ScheduleItem item = new ScheduleItem
				{
					CourseID = query.CourseID,
					EventDate = query.EventDate.Date,
					DurationHours = query.DurationHours,
					ScheduleItemID = query.ScheduleItemID,
					Note = query.Note
				};

				return item;
			}
		}
	}
}
